<template>
  <div align="center">
    <el-button @click="changeUserId"
               type="warning"
               style="margin-left: 800px;"
               size="medium"
               plain
    >切换用户</el-button>当前用户：{{this.queryForm.userId}}
    <el-table
        :data="tableData"
        style="width: 100%">
      <el-table-column
          prop="dealTime"
          label="成交时间"
          width="180">
      </el-table-column>
      <el-table-column
          prop="stoclName"
          label="股票名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="stockCode"
          width="180"
          label="股票代码">
      </el-table-column>
      <el-table-column
          prop="dealPrice"
          width="180"
          label="成交价格（元）">
      </el-table-column>
      <el-table-column
          prop="dealNum"
          label="成交数量（股）"
          width="180">
      </el-table-column>
      <el-table-column
          prop="dealMoney"
          width="180"
          label="成交金额">
      </el-table-column>
      <el-table-column
          prop="direction"
          label="方向"
          width="180">
      </el-table-column>
    </el-table>
    <el-pagination
        background
        :page-size="queryForm.pageSize"
        :current-page="queryForm.pageNum"
        layout="prev, pager, next"
        @current-change="toNewPage"
        :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "TodayDael",
  data(){
    return{
      tableData:[],
      total:0,
      queryForm:{
        pageNum:1,
        pageSize:3,
        userId:1,
      }
    }
  },
  created() {
    this.getDealList();
  },
  methods:{
    changeUserId(){
      if(this.queryForm.userId==1){
        this.queryForm.userId=4;
      }else {
        this.queryForm.userId=1;
      }
      this.getDealList();
    },
    getDealList(){
      this.queryForm.haveId=this.queryForm.userId;
      this.axios.post("http://localhost:8182/stock/getTodayDealList",this.queryForm).then(r=>{
        this.tableData=r.data.data.list;
        this.total=r.data.data.total;
      })
      this.queryForm.pageNum=1;
    },
    toNewPage(newPage){
      this.queryForm.pageNum=newPage;
      this.getDealList();
    }
  }
}
</script>

<style scoped>

</style>